<?php
namespace Admin\Model;

use Think\Model;

class ProductClassModel extends Model {
	
	const TYPE_AUTO = 0;
	const TYPE_ALWAYS_SELECTABLE = 1;
	
	public $selectTypes = array(
		'0' => '自动',
		'1' => '总是可选',
	);
	
	/**
	 * 获得类目的品牌(以邻进父级为准)
	 */
	public function getClassBrand( $clsId ) {
		do {
			$productClass = M("ProductClass")->find( $clsId );
			$clsId = $productClass['pid'];
			if( !empty($productClass['brand']) ) {
				return $productClass['brand'];
			}
		} while( $clsId != 0 );
		return null;
	}
	
	/**
	 * 获得类目的功效(以邻进父级为准)
	 */
	public function getClassEfficiency( $clsId ) {
		do {
			$productClass = M("ProductClass")->find( $clsId );
			$clsId = $productClass['pid'];
			if( !empty($productClass['efficiency']) ) {
				return $productClass['efficiency'];
			}
		} while( $clsId != 0 );
		return null;
	}
}